Add a "menu" property and notify on it. (#62798, Padraig O'Briain)
authorOwen Taylor <otaylor@redhat.com>
Wed, 31 Oct 2001 23:49:09 +0000 (23:49 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Wed, 31 Oct 2001 23:49:09 +0000 (23:49 +0000)
Wed Oct 31 18:23:47 2001  Owen Taylor  <otaylor@redhat.com>

* gtk/gtkoptionmenu.c (gtk_option_menu_detacher):
Add a "menu" property and notify on it. (#62798,
Padraig O'Briain)

* gtk/gtkselection.[ch] gtk/{gtkentry.c, gtkfilesel.c,
gtkoldeditable.c, gtktextbuffer.c, gtktextview.c}:
Fix set_text to take a gchar, not a guchar, and to have
a len argument.

17 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkclipboard.c
gtk/gtkentry.c
gtk/gtkfilesel.c
gtk/gtklabel.c
gtk/gtkoldeditable.c
gtk/gtkoptionmenu.c
gtk/gtkselection.c
gtk/gtkselection.h
gtk/gtktextbuffer.c
gtk/gtktextview.c

index 08510fc61e1ec69bdb5e7860f029485923a18ada..4a18077772461264ff587d58b7bd4d8bd4f9aad7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+Wed Oct 31 18:23:47 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkoptionmenu.c (gtk_option_menu_detacher): 
+       Add a "menu" property and notify on it. (#62798,
+       Padraig O'Briain)
+
+       * gtk/gtkselection.[ch] gtk/{gtkentry.c, gtkfilesel.c,
+       gtkoldeditable.c, gtktextbuffer.c, gtktextview.c}: 
+       Fix set_text to take a gchar, not a guchar, and to have 
+       a len argument.
+
 Wed Oct 31 15:31:13 2001  Manish Singh  <yosh@gimp.org>
 
        * gtk/gtkstock.c: fix typo to make it compile
index 08510fc61e1ec69bdb5e7860f029485923a18ada..4a18077772461264ff587d58b7bd4d8bd4f9aad7 100644 (file)
@@ -1,3 +1,14 @@
+Wed Oct 31 18:23:47 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkoptionmenu.c (gtk_option_menu_detacher): 
+       Add a "menu" property and notify on it. (#62798,
+       Padraig O'Briain)
+
+       * gtk/gtkselection.[ch] gtk/{gtkentry.c, gtkfilesel.c,
+       gtkoldeditable.c, gtktextbuffer.c, gtktextview.c}: 
+       Fix set_text to take a gchar, not a guchar, and to have 
+       a len argument.
+
 Wed Oct 31 15:31:13 2001  Manish Singh  <yosh@gimp.org>
 
        * gtk/gtkstock.c: fix typo to make it compile
index 08510fc61e1ec69bdb5e7860f029485923a18ada..4a18077772461264ff587d58b7bd4d8bd4f9aad7 100644 (file)
@@ -1,3 +1,14 @@
+Wed Oct 31 18:23:47 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkoptionmenu.c (gtk_option_menu_detacher): 
+       Add a "menu" property and notify on it. (#62798,
+       Padraig O'Briain)
+
+       * gtk/gtkselection.[ch] gtk/{gtkentry.c, gtkfilesel.c,
+       gtkoldeditable.c, gtktextbuffer.c, gtktextview.c}: 
+       Fix set_text to take a gchar, not a guchar, and to have 
+       a len argument.
+
 Wed Oct 31 15:31:13 2001  Manish Singh  <yosh@gimp.org>
 
        * gtk/gtkstock.c: fix typo to make it compile
index 08510fc61e1ec69bdb5e7860f029485923a18ada..4a18077772461264ff587d58b7bd4d8bd4f9aad7 100644 (file)
@@ -1,3 +1,14 @@
+Wed Oct 31 18:23:47 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkoptionmenu.c (gtk_option_menu_detacher): 
+       Add a "menu" property and notify on it. (#62798,
+       Padraig O'Briain)
+
+       * gtk/gtkselection.[ch] gtk/{gtkentry.c, gtkfilesel.c,
+       gtkoldeditable.c, gtktextbuffer.c, gtktextview.c}: 
+       Fix set_text to take a gchar, not a guchar, and to have 
+       a len argument.
+
 Wed Oct 31 15:31:13 2001  Manish Singh  <yosh@gimp.org>
 
        * gtk/gtkstock.c: fix typo to make it compile
index 08510fc61e1ec69bdb5e7860f029485923a18ada..4a18077772461264ff587d58b7bd4d8bd4f9aad7 100644 (file)
@@ -1,3 +1,14 @@
+Wed Oct 31 18:23:47 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkoptionmenu.c (gtk_option_menu_detacher): 
+       Add a "menu" property and notify on it. (#62798,
+       Padraig O'Briain)
+
+       * gtk/gtkselection.[ch] gtk/{gtkentry.c, gtkfilesel.c,
+       gtkoldeditable.c, gtktextbuffer.c, gtktextview.c}: 
+       Fix set_text to take a gchar, not a guchar, and to have 
+       a len argument.
+
 Wed Oct 31 15:31:13 2001  Manish Singh  <yosh@gimp.org>
 
        * gtk/gtkstock.c: fix typo to make it compile
index 08510fc61e1ec69bdb5e7860f029485923a18ada..4a18077772461264ff587d58b7bd4d8bd4f9aad7 100644 (file)
@@ -1,3 +1,14 @@
+Wed Oct 31 18:23:47 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkoptionmenu.c (gtk_option_menu_detacher): 
+       Add a "menu" property and notify on it. (#62798,
+       Padraig O'Briain)
+
+       * gtk/gtkselection.[ch] gtk/{gtkentry.c, gtkfilesel.c,
+       gtkoldeditable.c, gtktextbuffer.c, gtktextview.c}: 
+       Fix set_text to take a gchar, not a guchar, and to have 
+       a len argument.
+
 Wed Oct 31 15:31:13 2001  Manish Singh  <yosh@gimp.org>
 
        * gtk/gtkstock.c: fix typo to make it compile
index 08510fc61e1ec69bdb5e7860f029485923a18ada..4a18077772461264ff587d58b7bd4d8bd4f9aad7 100644 (file)
@@ -1,3 +1,14 @@
+Wed Oct 31 18:23:47 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkoptionmenu.c (gtk_option_menu_detacher): 
+       Add a "menu" property and notify on it. (#62798,
+       Padraig O'Briain)
+
+       * gtk/gtkselection.[ch] gtk/{gtkentry.c, gtkfilesel.c,
+       gtkoldeditable.c, gtktextbuffer.c, gtktextview.c}: 
+       Fix set_text to take a gchar, not a guchar, and to have 
+       a len argument.
+
 Wed Oct 31 15:31:13 2001  Manish Singh  <yosh@gimp.org>
 
        * gtk/gtkstock.c: fix typo to make it compile
index 655623173371c9931ab0197e3a9c175221b265cd..dab3d3e051754714d17cae085733bf3d1d1d509d 100644 (file)
@@ -498,7 +498,7 @@ text_get_func (GtkClipboard     *clipboard,
               guint             info,
               gpointer          data)
 {
-  gtk_selection_data_set_text (selection_data, data);
+  gtk_selection_data_set_text (selection_data, data, -1);
 }
 
 static void 
index d2426f08e1f834617db4e5e9a63d4b39db9039ee..e3a8804bdc9e3c46962c032e232dcac325f80180 100644 (file)
@@ -3172,7 +3172,7 @@ primary_get_cb (GtkClipboard     *clipboard,
   if (gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &start, &end))
     {
       gchar *str = gtk_entry_get_public_chars (entry, start, end);
-      gtk_selection_data_set_text (selection_data, str);
+      gtk_selection_data_set_text (selection_data, str, -1);
       g_free (str);
     }
 }
@@ -4025,7 +4025,7 @@ gtk_entry_drag_data_get (GtkWidget        *widget,
     {
       gchar *str = gtk_editable_get_chars (editable, sel_start, sel_end);
 
-      gtk_selection_data_set_text (selection_data, str);
+      gtk_selection_data_set_text (selection_data, str, -1);
       
       g_free (str);
     }
index 5c7f255dd40633c386a8ed350eff503dada8fbc2..baeba13b34a2759e1c3099b36e6d8ecde5c055b8 100644 (file)
@@ -915,7 +915,7 @@ filenames_drag_get (GtkWidget        *widget,
       else
        {
          g_print ("Setting text: '%s'\n", file);
-         gtk_selection_data_set_text (selection_data, file);
+         gtk_selection_data_set_text (selection_data, file, -1);
        }
     }
 }
index 776caa996c65c63914e1d8a179b0ca1bd47035ac..87f1d51dfe2cce6370054b00f5d358f85a81bf86 100644 (file)
@@ -2406,7 +2406,6 @@ get_text_callback (GtkClipboard     *clipboard,
                    gpointer          user_data_or_owner)
 {
   GtkLabel *label;
-  gchar *str;
   
   label = GTK_LABEL (user_data_or_owner);
   
@@ -2430,13 +2429,9 @@ get_text_callback (GtkClipboard     *clipboard,
       if (start > len)
         start = len;
 
-      str = g_strndup (label->text + start,
-                       end - start);
-      
-      gtk_selection_data_set_text (selection_data, 
-                                   str);
-
-      g_free (str);
+      gtk_selection_data_set_text (selection_data,
+                                  label->text + start,
+                                  end - start);
     }
 }
 
index f67952807e5e6ff1be66d1d6539b22702ff8e844..caca8890c1df06ccdb6341ab7948d5b45be6f0c9 100644 (file)
@@ -584,7 +584,7 @@ gtk_old_editable_selection_get (GtkWidget        *widget,
 
   if (str)
     {
-      gtk_selection_data_set_text (selection_data, str);
+      gtk_selection_data_set_text (selection_data, str, -1);
       g_free (str);
     }
 }
index 6d284a3f307ce3fdbfc9ebcd549570595edc149b..2d311f5a38ecb8191d1d2d4926fcb6b53fc0568a 100644 (file)
@@ -55,6 +55,14 @@ static GtkOptionMenuProps default_props = {
 static void gtk_option_menu_class_init      (GtkOptionMenuClass *klass);
 static void gtk_option_menu_init            (GtkOptionMenu      *option_menu);
 static void gtk_option_menu_destroy         (GtkObject          *object);
+static void gtk_option_menu_set_property    (GObject            *object,
+                                            guint               prop_id,
+                                            const GValue       *value,
+                                            GParamSpec         *pspec);
+static void gtk_option_menu_get_property    (GObject            *object,
+                                            guint               prop_id,
+                                            GValue             *value,
+                                            GParamSpec         *pspec);
 static void gtk_option_menu_size_request    (GtkWidget          *widget,
                                             GtkRequisition     *requisition);
 static void gtk_option_menu_size_allocate   (GtkWidget          *widget,
@@ -91,6 +99,13 @@ enum
   LAST_SIGNAL
 };
 
+enum
+{
+  PROP_0,
+  PROP_MENU,
+  LAST_PROP
+};
+
 static GtkButtonClass *parent_class = NULL;
 static guint           signals[LAST_SIGNAL] = { 0 };
 
@@ -123,11 +138,13 @@ gtk_option_menu_get_type (void)
 static void
 gtk_option_menu_class_init (GtkOptionMenuClass *class)
 {
+  GObjectClass *gobject_class;
   GtkObjectClass *object_class;
   GtkWidgetClass *widget_class;
   GtkButtonClass *button_class;
   GtkContainerClass *container_class;
 
+  gobject_class = (GObjectClass*) class;
   object_class = (GtkObjectClass*) class;
   widget_class = (GtkWidgetClass*) class;
   button_class = (GtkButtonClass*) class;
@@ -143,7 +160,9 @@ gtk_option_menu_class_init (GtkOptionMenuClass *class)
                   NULL, NULL,
                   gtk_marshal_VOID__VOID,
                   G_TYPE_NONE, 0);
-  
+
+  gobject_class->set_property = gtk_option_menu_set_property;
+  gobject_class->get_property = gtk_option_menu_get_property;
   object_class->destroy = gtk_option_menu_destroy;
   
   widget_class->size_request = gtk_option_menu_size_request;
@@ -158,6 +177,14 @@ gtk_option_menu_class_init (GtkOptionMenuClass *class)
 
   container_class->child_type = gtk_option_menu_child_type;
 
+  g_object_class_install_property (gobject_class,
+                                   PROP_MENU,
+                                   g_param_spec_object ("menu",
+                                                        _("Menu"),
+                                                        _("The menu of options"),
+                                                        GTK_TYPE_MENU,
+                                                        G_PARAM_READABLE | G_PARAM_WRITABLE));
+  
   gtk_widget_class_install_style_property (widget_class,
                                           g_param_spec_boxed ("indicator_size",
                                                               _("Indicator Size"),
@@ -220,6 +247,7 @@ gtk_option_menu_detacher (GtkWidget     *widget,
                                 option_menu);
   
   option_menu->menu = NULL;
+  g_object_notify (G_OBJECT (option_menu), "menu");
 }
 
 void
@@ -251,6 +279,8 @@ gtk_option_menu_set_menu (GtkOptionMenu *option_menu,
        gtk_widget_queue_resize (GTK_WIDGET (option_menu));
 
       gtk_option_menu_update_contents (option_menu);
+      
+      g_object_notify (G_OBJECT (option_menu), "menu");
     }
 }
 
@@ -311,6 +341,46 @@ gtk_option_menu_get_history (GtkOptionMenu *option_menu)
     return -1;
 }
 
+static void
+gtk_option_menu_set_property (GObject            *object,
+                             guint               prop_id,
+                             const GValue       *value,
+                             GParamSpec         *pspec)
+{
+  GtkOptionMenu *option_menu = GTK_OPTION_MENU (object);
+
+  switch (prop_id)
+    {
+    case PROP_MENU:
+      gtk_option_menu_set_menu (option_menu, g_value_get_object (value));
+      break;
+      
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static void
+gtk_option_menu_get_property (GObject            *object,
+                             guint               prop_id,
+                             GValue             *value,
+                             GParamSpec         *pspec)
+{
+  GtkOptionMenu *option_menu = GTK_OPTION_MENU (object);
+
+  switch (prop_id)
+    {
+    case PROP_MENU:
+      g_value_set_object (value, option_menu->menu);
+      break;
+      
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
 static void
 gtk_option_menu_destroy (GtkObject *object)
 {
index 21bcb510be6d3bc89395088e71d2cab2d32031d7..bb5afe8ed1d7fc076a52bfa50adecfe1c5f15428 100644 (file)
@@ -769,6 +769,7 @@ init_atoms (void)
  * gtk_selection_data_set_text:
  * @selection_data: a #GtkSelectionData
  * @str: a UTF-8 string
+ * @len: the length of @str, or -1 if @str is nul-terminated.
  * 
  * Sets the contents of the selection from a UTF-8 encoded string.
  * The string is converted to the form determined by
@@ -779,50 +780,62 @@ init_atoms (void)
  **/
 gboolean
 gtk_selection_data_set_text (GtkSelectionData     *selection_data,
-                            const guchar         *str)
+                            const gchar          *str,
+                            gint                  len)
 {
+  gboolean result = FALSE;
+  
+  if (len < 0)
+    len = strlen (str);
+  
   init_atoms ();
 
   if (selection_data->target == utf8_atom)
     {
       gtk_selection_data_set (selection_data,
                              utf8_atom,
-                             8, (guchar *)str, strlen (str));
-      return TRUE;
+                             8, (guchar *)str, len);
+      result = TRUE;
     }
   else if (selection_data->target == GDK_TARGET_STRING)
     {
-      gchar *latin1 = gdk_utf8_to_string_target (str);
+      gchar *tmp = g_strndup (str, len);
+      gchar *latin1 = gdk_utf8_to_string_target (tmp);
+      g_free (tmp);
 
       if (latin1)
        {
          gtk_selection_data_set (selection_data,
                                  GDK_SELECTION_TYPE_STRING,
                                  8, latin1, strlen (latin1));
-         g_free(latin1);
+         g_free (latin1);
          
-         return TRUE;
+         result = TRUE;
        }
 
     }
   else if (selection_data->target == ctext_atom ||
           selection_data->target == text_atom)
     {
+      gchar *tmp;
       guchar *text;
       GdkAtom encoding;
       gint format;
       gint new_length;
-      
-      if (gdk_utf8_to_compound_text (str, &encoding, &format, &text, &new_length))
+
+      tmp = g_strndup (str, len);
+      if (gdk_utf8_to_compound_text (tmp, &encoding, &format, &text, &new_length))
        {
          gtk_selection_data_set (selection_data, encoding, format, text, new_length);
          gdk_free_compound_text (text);
-      
-         return TRUE;
+
+         result = TRUE;
        }
+
+      g_free (tmp);
     }
   
-  return FALSE;
+  return result;
 }
 
 /**
index cf6b887a871b87f0c52f760089b7e50e76760447..76036e9f100823951a1e07615515c161d745c10f 100644 (file)
@@ -126,7 +126,8 @@ void     gtk_selection_data_set      (GtkSelectionData     *selection_data,
                                      const guchar         *data,
                                      gint                  length);
 gboolean gtk_selection_data_set_text (GtkSelectionData     *selection_data,
-                                     const guchar         *str);
+                                     const gchar          *str,
+                                     gint                  len);
 guchar * gtk_selection_data_get_text (GtkSelectionData     *selection_data);
 
 gboolean gtk_selection_data_get_targets          (GtkSelectionData  *selection_data,
index 4663c644db2caf71a4d491705e566c118caff3d2..5cbc44cb75ccd1f5d5348afca46ec3db036033fd 100644 (file)
@@ -2560,7 +2560,7 @@ clipboard_get_selection_cb (GtkClipboard     *clipboard,
           gchar *str;
           
           str = gtk_text_iter_get_visible_text (&start, &end);
-          gtk_selection_data_set_text (selection_data, str);
+          gtk_selection_data_set_text (selection_data, str, -1);
           g_free (str);
         }
     }
@@ -2679,7 +2679,7 @@ clipboard_get_contents_cb (GtkClipboard     *clipboard,
       gtk_text_buffer_get_bounds (contents, &start, &end);
       
       str = gtk_text_iter_get_visible_text (&start, &end);
-      gtk_selection_data_set_text (selection_data, str);
+      gtk_selection_data_set_text (selection_data, str, -1);
       g_free (str);
     }
 }
index 51d826410bf63ef4c889ac7f688cc945e999d7f3..d45b1891ab3f9345aa61cf593da842babeee64ba 100644 (file)
@@ -4799,7 +4799,7 @@ gtk_text_view_drag_data_get (GtkWidget        *widget,
 
       if (str)
         {
-          gtk_selection_data_set_text (selection_data, str);
+          gtk_selection_data_set_text (selection_data, str, -1);
           g_free (str);
         }
     }